package com.yfp.org.mq;

import com.yfp.common.core.exception.ServiceException;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

@Getter
@AllArgsConstructor
public enum RefundStatus {

    // 退款中
    Refunding(6, "Refunding"),
    // 失败
    Failed(7,"Failed"),
    // 成功
    Success(4,"Success");

    private int code;
    private String refundStatus;
    public static RefundStatus getRefundStatus(String  refundStatus){
        for (RefundStatus status : RefundStatus.values()) {
            if (status.refundStatus.equals(refundStatus)){
                return status;
            }
        }
        throw new ServiceException("退款状态不存在");
    }

    public static void main(String[] args) {
        System.out.println(Objects.requireNonNull(RefundStatus.getRefundStatus("Refunding")).getCode());
    }
}